package com.aiyige.page.selectinterest.model;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2017/10/25.
 */

public class IndustryItem {
    String id;
    String title;
    int selectNum;
    boolean stats;
    boolean selected;
    List<InterestItem> interestItemList=new LinkedList<>();

    public IndustryItem() {
        stats = false;
        selectNum = 0;
    }

    public IndustryItem(boolean stats) {
        this.stats = stats;
        selected = stats;
    }

    public List<InterestItem> getInterestItemList() {
        return interestItemList;
    }

    public void setInterestItemList(List<InterestItem> interestItemList) {
        this.interestItemList = interestItemList;
    }

    public void clearAllInterestSelectedState() {
        if (interestItemList == null) return;
        for (InterestItem item : interestItemList) {
            item.setSelected(false);
        }
    }

    public List<InterestItem> getSelectedInterestItemList() {
        List<InterestItem> selectedList = new LinkedList<>();
        if (interestItemList != null && !interestItemList.isEmpty()) {
            for (InterestItem i : interestItemList) {
                if (i.isSelected()) {
                    selectedList.add(i);
                }
            }
        }
        return selectedList;
    }

    public void clearInterestSelectedStateById(String id) {
        if (interestItemList == null) return;
        for (InterestItem item : interestItemList) {
            if (item.getId().equals(id)) {
                item.setSelected(false);
            }
        }
    }


    public boolean isSelectedAll() {
        boolean result = true;
        if (interestItemList != null && !interestItemList.isEmpty()) {
            for (InterestItem i : interestItemList) {
                if (!i.isSelected()) {
                    result = false;
                    break;
                }
            }
        } else {
            result = false;
        }
        return result;
    }


    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getSelectNum() {
        return selectNum;
    }

    public void setSelectNum(int selectNum) {
        this.selectNum = selectNum;
    }

    public boolean isStats() {
        return stats;
    }

    public void setStats(boolean stats) {
        this.stats = stats;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public static final IndustryItem STATE = new IndustryItem(true);

}
